<?php

namespace App\Http\Validate\Order;

use App\Http\Validate\BaseValidate;

/**
 * 退货子订单验证器
 */
class Returnordersub extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'archive_no' => 'required',
                'warehouse_name' => 'required',
                'steel_factory_name' => 'required',
                'archive_type' => 'required',
                'archive_name' => 'required',
                'archive_spec' => 'required',
                'archive_material' => 'required',
                'breed_name' => 'required',
                'weight' => 'required',
                'unit_price' => 'required',
                'total' => 'required',
            ];
            $this->message = [
                'archive_no.required' => '钢材编码不能为空',
                'warehouse_name.required' => '仓库名称不能为空',
                'steel_factory_name.required' => '钢厂不能为空',
                'archive_type.required' => '码单类型不能为空',
                'archive_name.required' => '品名不能为空',
                'archive_spec.required' => '规格不能为空',
                'archive_material.required' => '材质不能为空',
                'breed_name.required' => '品种不能为空',
                'weight.required' => '重量不能为空',
                'unit_price.required' => '单价不能为空',
                'total.required' => '金额不能为空',
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required',
                'archive_no' => 'required',
                'warehouse_name' => 'required',
                'steel_factory_name' => 'required',
                'archive_type' => 'required',
                'archive_name' => 'required',
                'archive_spec' => 'required',
                'archive_material' => 'required',
                'breed_name' => 'required',
                'weight' => 'required',
                'unit_price' => 'required',
                'total' => 'required',
            ];
            $this->message = [
                'id.required' => 'id不能为空',
                'archive_no.required' => '钢材编码不能为空',
                'warehouse_name.required' => '仓库名称不能为空',
                'steel_factory_name.required' => '钢厂不能为空',
                'archive_type.required' => '码单类型不能为空',
                'archive_name.required' => '品名不能为空',
                'archive_spec.required' => '规格不能为空',
                'archive_material.required' => '材质不能为空',
                'breed_name.required' => '品种不能为空',
                'weight.required' => '重量不能为空',
                'unit_price.required' => '单价不能为空',
                'total.required' => '金额不能为空',
            ];
        } elseif ($doaction == 'handlereturn') {
            $this->rule = [
                'id' => 'required',
                'return_status' => 'required|in:2,4,5',
            ];
            $this->message = [
                'id.required' => 'id不能为空',
                'return_status.required' => '退货状态不能为空',
                'return_status.in' => '参数非法',
            ];
        }
    }
}
